package com.gxuwz.action;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.gxuwz.core.web.action.BaseAction;
import com.gxuwz.pojo.Form;
import com.gxuwz.pojo.SysUser;
import com.gxuwz.service.IDataService;
import com.gxuwz.service.IFormService;
import com.gxuwz.service.ITopicService;
import com.gxuwz.util.MailUtil;
import com.opensymphony.xwork2.ModelDriven;
import com.opensymphony.xwork2.Preparable;

public class MailAction extends BaseAction implements Preparable, ModelDriven<Form>{


	@Autowired
	private IFormService formService;
	@Autowired
	private ITopicService topicService;
	@Autowired
	private IDataService dataService;
	
	private Form form;
	
	public void send(){
		form = formService.findById(form.getId());
		//查询该表格未填写用户集合
		List<SysUser> userList = dataService.getMailUser("data_"+form.getId());
		//发送邮件
		try{
			MailUtil.sendByEmail(userList);
		}catch(Exception e){
			System.out.println(e);
		}
		
	}

	public Form getForm() {
		return form;
	}

	public void setForm(Form form) {
		this.form = form;
	}

	@Override
	public Form getModel() {
		// TODO Auto-generated method stub
		return form;
	}

	@Override
	public void prepare() throws Exception {
		// TODO Auto-generated method stub
		form = new Form();
	}
	

	
	
	
}
